﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace VlcPlayer
{
    public partial class AddUrl : PhoneApplicationPage
    {
        public AddUrl()
        {
            InitializeComponent();

            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).Text = AppResources.OK;
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).Text = AppResources.Cancel;

#if DEBUG
            NavigationUrl.Text = "http://dm800:8001/1:0:1:8:2:85:C00000:0:0:0:";
#endif
        }

        private string _host;
        private string _svId;

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            _svId = NavigationContext.QueryString["svId"];
            _host = NavigationContext.QueryString["host"];
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            //OK
#if WP70
            if (!string.IsNullOrEmpty(NavigationUrl.Text))
#else
            if (!string.IsNullOrWhiteSpace(NavigationUrl.Text))
#endif
            {
                NavigationService.Navigate(new Uri(@"/PlayerPage.xaml?svId=" + _svId + "&src=" + NavigationUrl.Text, UriKind.Relative));
            }
        }

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            //cancel
            NavigationService.GoBack();
        }
    }
}